package com.example.replacebooks.mapper;

import com.example.replacebooks.entity.Class;
import com.example.replacebooks.entity.Message;
import com.example.replacebooks.entity.Params;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface MessageMapper extends Mapper<Message> {
    List<Message> findBySearch(@Param("params") Params params,@Param("bookid") Integer bookid);

    @Select("select * from message where messageid = #{messageid} limit 1")
    Message findByMessageid(@Param("messageid") Integer messageid);

    @Update("update message set readstatu=#{readstatu},messagetype = #{messagetype},message = #{message},messagetime = #{messagetime},userid = #{userid},touserid = #{touserid},bookid = #{bookid} where messageid =#{messageid}")
    void updateByMessageid(Message message);

    List<Message> findBySearchByread(@Param("params") Params params,@Param("userid") Integer userid);

    @Update("update message set readstatu=#{readstatu} where messageid =#{messageid}")
    void updateByMessageidToReadstatu(Message message);
}

